package com.example.hrsystem.data.source;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import com.example.hrsystem.workflow.model.ApprovalRequest;

import java.util.List;

/**
 * 审批请求数据库访问接口
 * 提供对所有类型审批请求的基础操作
 */
@Dao
public interface ApprovalRequestDao {
    /**
     * 获取所有审批请求
     */
    @Query("SELECT * FROM approval_requests")
    List<ApprovalRequest> getAllRequests();

    /**
     * 根据ID获取审批请求
     */
    @Query("SELECT * FROM approval_requests WHERE id = :id")
    ApprovalRequest getRequestById(int id);

    /**
     * 根据流程实例ID获取审批请求
     */
    @Query("SELECT * FROM approval_requests WHERE processInstanceId = :processInstanceId")
    ApprovalRequest getRequestByProcessInstanceId(int processInstanceId);

    /**
     * 根据申请人ID获取审批请求列表
     */
    @Query("SELECT * FROM approval_requests WHERE applicantId = :applicantId")
    List<ApprovalRequest> getRequestsByApplicantId(int applicantId);

    /**
     * 根据状态获取审批请求列表
     */
    @Query("SELECT * FROM approval_requests WHERE status = :status")
    List<ApprovalRequest> getRequestsByStatus(String status);

    /**
     * 根据请求类型获取审批请求列表
     */
    @Query("SELECT * FROM approval_requests WHERE requestType = :requestType")
    List<ApprovalRequest> getRequestsByType(String requestType);

    /**
     * 插入审批请求
     */
    @Insert
    void insert(ApprovalRequest request);

    /**
     * 更新审批请求
     */
    @Update
    void update(ApprovalRequest request);

    /**
     * 删除审批请求
     */
    @Delete
    void delete(ApprovalRequest request);
}